{% extends "blog/blog.html" %}
{% load string %}
{% load i18n %} 
{% load ytcomment %}
{% load ytutil %}

{% block description %}
  <meta name="description" content="{% for tag in post.tags %}{{ tag|escape }}, {% endfor %}{{post.title|escape}}">
{% endblock %}

{% block content %}
  {% include "blog/div_blog.html" %}
  
  {% get_comment_list for post as comments paginator page comment_num_per_page descending %}
  <div>
  {% for comment in comments %}
    <div class="post">
    
	    <div class="CommentTitle">
	    {{ comment.author.get_name }} {{ comment.date|timedelta|date:"Y-m-d H:i" }}
	    </div>
	    
	    <div class="CommentText">{{ comment.content|removetags:"script"|safe }}</div>
	
		  <div class="BlogOperation">
		  
		  {% if comment.auth.delete %}
		  <div class="BlogButton" 
		    onclick="$.post('{% url ytcommunity.blog.view.comment.delete comment.key.id %}', 
                function(data){document.location.reload(true);});">
		    <span>{% trans 'Delete' %}</span>
		  </div>
		  {% endif %}
		
		  </div>

    </div>
  {% endfor %}
  </div>

	<div id="BlogPagination" class="pagination">
	{% if page.prev %}
	<a class="prev" href="{% url ytcommunity.blog.view.blog.display post.key.id %}?page={{page.prev_page}}">{% trans 'Previous Page' %}</a>
	{% endif %}
	{% if page.next %}
	<a class="next" href="{% url ytcommunity.blog.view.blog.display post.key.id %}?page={{page.next_page}}">{% trans 'Next Page' %}</a>
	{% endif %}
	</div>
    
  <div class="CommentAdd">
  {% if auth_comment.add %}
  <form action="{% url ytcommunity.blog.view.comment.add post.key.id %}" method="post">
    <div class="fieldWrapper">
        {{ form.content.errors }}
        <label for="id_content">{% trans "Add Comment" %}:</label><br>
        {{ form.content }}
    </div>    
    
    <div>
    <input type="submit" class="button" value="{% trans 'Add' %}">
    </div>
  </form>

  {% endif %}
  </div>
  
{% endblock %}